<?php
class WebUser extends CWebUser{
	public function getLastLogin(){
		$user = User::model()->findByPk($this->id);
		return $user?$user->lastlogin:'';
	}
	public function getManageMenu(){
		$assignments = Assignments::model()->findAllByAttributes(array('userid'=>$this->id));
		$assignmentsMenuMap = array(
				'CategoryManager'=>array('label'=>'分类管理', 'url'=>array('/manage/category/admin')),
				'PermissionManager'=>array('label'=>'权限管理', 'url'=>array('/srbac/authitem/manage')),
				'ProductManager'=>array('label'=>'商品管理', 'url'=>array('/manage/product/admin')),
				'UserManager'=>array('label'=>'用户管理', 'url'=>array('/manage/user/admin')),
				'OrderManager'=>array('label'=>'订单管理','url'=>array('/manage/order/admin'))
		);
		$menuItems = array();
		if($assignments){
			foreach($assignments as $as){
				if(isset($assignmentsMenuMap[$as->itemname])){
					$menuItems[] = $assignmentsMenuMap[$as->itemname];
				}
			}
		}
		
		return $menuItems;
		
	}
}